<link href="/Public/Home/public/all_common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://lib.h-ui.net/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/Public/Home/jquery.provincesCity.js"></script>
<script type="text/javascript" src="/Public/Home/provincesData.js"></script>

<div class="xlj-edit-addr-backdrop" id="AddrBackdrop" ></div>
<div class="xlj-edit-addr-box" id="editAddrBox">
    <form action="" method="post" name="theFormAddress" onsubmit="return checkConsignee(this)">
        <div class="bd">
            <div class="item">
                <label>收货人姓名</label>
                <input type="text" name="consignee" id="name" class="input" placeholder="收货人姓名" maxlength="15" autocomplete="off" value="<?php echo $arr['name']?>">

            </div>
            <div class="item">
                <label>联系电话</label><input type="text" name="phone" class="input" id="phone" placeholder="11位手机号" autocomplete="off" value="<?php echo $arr['phone']?>">
            </div>

            <div class="item">
                <!--三级联动-->
                <div id="province"></div>
            </div>
            <?php if($_GET['F']=='dz_edit'){?>
                <?php echo $arr['dizhi']?>(不选择代表不修改)
            <?php }?>
            <div class="item">
                <label>路名或街道地址，门牌号</label>
                <textarea name="address" class="input-area" id="dizhi_msg" placeholder="路名或街道地址，门牌号"><?php echo $arr['dizhi_msg']?></textarea>
            </div>
            <div class="item">
                <label>邮政编码</label><input type="text" name="zipcode" id="yzcode" class="input zipcode" placeholder="邮政编码" autocomplete="off" value="<?php echo $arr['yzcode']?>">
            </div>
            <div class="item ft">
                <input type="submit" class="btn  btn-primary btn-ok" id="addOk" value="确认收货地址" />
                <input type="button" class="btn   btn-back " id="addBack" value="取消" />
            </div>
        </div>
    </form>
    <script type="text/javascript">
        /*调用插件*/
        $(function(){
            var F="<?php echo $_GET['F'];?>";
            //取消关闭当前窗口
            $('#addBack').click(function () {
                var indx=parent.layer.getFrameIndex(window.name);
                parent.layer.close(indx);
            });

            $("#province").ProvinceCity();// 三级联动初始化

            $('#addOk').click(function () {
                //获取数据
                var name=$("#name").val();
                var phone=$("#phone").val();
                var dizhi=$("#dizhi").val();
                var dizhi_msg=$("#dizhi_msg").val();
                var yzcode=$("#yzcode").val();
                //三级联动
                var dizi='';
                $("select").each(function (i,t) {
                    dizi+=$(t).val()+'|';
                });

                //判断是修改还是推荐
                if(F=='dz_edit'){
                    var url="<?php $this->U('Order','dz_edit')?>";
                    var data={name,phone,dizhi,dizhi_msg,yzcode,dizi,id:"<?php echo $arr['id']?>"};
                }else{
                    var url="<?php $this->U('Order','dz_add')?>";
                    var data={name,phone,dizhi,dizhi_msg,yzcode,dizi};
                }

                //ajax 提交数据
                $.post(url,data,function (abc) {
                    alert(abc.msg);
                    if(abc.type){
                        //刷新父页面,关闭自己窗口
                        parent.location.reload();//刷新父窗口
                        var indx=parent.layer.getFrameIndex(window.name);
                        parent.layer.close(indx);
                    }
                },'json');

                return false;
            })
        });
    </script>
</div>

